package com.dfbz.demo01_普通内部类;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_普通内部类的用法 {

    public static void main(String[] args) {

        Computer computer=new Computer("神舟",2888.8D);
        computer.show();

        System.out.println("-------------");
        // 内部类想要初始化必须先初始化外部类
//        Computer.CPU cpu=computer.new CPU("i9 12900KS","12","20");

        Computer.CPU cpu=new Computer("小米",8999.9D).new CPU("i9 12900KS","12","20");
        cpu.show();



    }
}

class Computer {

    private String brand;
    private Double price;

    public Computer(String brand, Double price) {
        this.brand = brand;
        this.price = price;
    }

    public void show() {
        System.out.println("品牌【" + brand + "】，价格【" + price + "】");
    }

    // 成员内部类
    class CPU {
        private String name;
        private String cores;
        private String threads;

        public CPU(String name, String cores, String threads) {
            this.name = name;
            this.cores = cores;
            this.threads = threads;
        }

        public void show() {
            System.out.println("品牌【" + brand + "】，价格【" + price + "】");
            System.out.println("CPU【" + name + "】，核心数【" + cores + "】，线程数【" + threads + "】");
        }

    }


}
